package com.car.controller;


import com.car.model.auto.Notice;
import com.car.model.auto.User;
import com.car.service.INoticeService;
import com.car.service.IUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 达瓦里氏
 * @since 2021-11-30
 */
@RestController
@RequestMapping("/notice")
@CrossOrigin
public class NoticeController {

    @Resource
    private INoticeService iNoticeService;

    /*查询通知*/
    @GetMapping("/getNotice")
    public List<Notice> getNotice(){
        return iNoticeService.list();
    }

    /*通过id查询通知*/
    @GetMapping("/getNoticeById/{id}")
    public Notice getNoticeById(@PathVariable("id") int id){
        return iNoticeService.getById(id);
    }

    /*修改通知*/
    @PostMapping("/updateNotice")
    public void updateNotice(@RequestBody Notice notice){
        iNoticeService.updateById(notice);
    }

    /*添加通知*/
    @PostMapping("/setNotice")
    public void setNotice(@RequestBody Notice notice){
        iNoticeService.save(notice);
    }

    /*删除通知*/
    @PostMapping("/deletedById/{id}")
    public boolean deleted(@PathVariable("id") int id){
        return iNoticeService.removeById(id);
    }
}
